let cache = new Map()

const { timeStamp } = require("console")
let fs = require("fs")
let info = (fs.readFileSync("C:/Users/yangyangwang/Desktop/common/todo/公司面试题测试/stu.txt")).toString()
let classInfos = info.split("\n")
for (let i = 0;i<classInfos.length;i++){ 
    let temps = classInfos[i].split("|")
    let score = parseInt(temps[2])
    let classname = temps[1]
    let stu = temps[0]
    if (cache.get(classname)) {
        let classInfo = cache.get(classname)
        if (classInfo.score<score){
            cache.set(classname,{class:classname,stu:stu,score:score})
        }
    }else {
        cache.set(classname,{class:classname,stu:stu,score:score})
    }
}
console.info(cache)
cache.forEach(
    function(classInfo){
        console.log(classInfo.class,classInfo.stu)
    }
)
for (var classname in cache) {
    classInfo = cache[classname]
    console.info(classInfo)
}
// cache.set("123",{class:"123",stu:"abc",score:12})

// cache.set("1234",{class:"123",stu:"abc",score:12})
// cache.set("1234",{class:"123",stu:"abc",score:13})
